a61144
@@ -119,10 +119,6 @@
private void createTxnManager() throws SemanticException {
         throw new SemanticException(e.getMessage(), e);
       }
     }
-    // the reason that we set the txn manager for the cxt here is because each
-    // query has its own ctx object. The txn mgr is shared across the
-    // same instance of Driver, which can run multiple queries.
-    ctx.setHiveTxnManager(txnMgr);
   }
 
   private boolean checkConcurrency() throws SemanticException {
@@ -814,7 +810,7 @@
public QueryPlan getPlan() {
   private int recordValidTxns() {
     try {
       ValidTxnList txns = txnMgr.getValidTxns();
-      ctx.getConf().set(ValidTxnList.VALID_TXNS_KEY, txns.toString());
+      conf.set(ValidTxnList.VALID_TXNS_KEY, txns.toString());
       return 0;
     } catch (LockException e) {
       errorMessage = "FAILED: Error in determing valid transactions: " + e.getMessage();
@@ -993,13 +989,6 @@
private CommandProcessorResponse runInternal(String command, boolean alreadyComp
     perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.TIME_TO_SUBMIT);
 
     int ret;
-    if (!alreadyCompiled) {
-      ret = compileInternal(command);
-      if (ret != 0) {
-        return new CommandProcessorResponse(ret, errorMessage, SQLState);
-      }
-    }
-
     boolean requireLock = false;
     boolean ckLock = false;
     try {
@@ -1014,6 +1003,20 @@
private CommandProcessorResponse runInternal(String command, boolean alreadyComp
       ret = 10;
       return new CommandProcessorResponse(ret, errorMessage, SQLState);
     }
+    ret = recordValidTxns();
+    if (ret != 0) return new CommandProcessorResponse(ret, errorMessage, SQLState);
+
+    if (!alreadyCompiled) {
+      ret = compileInternal(command);
+      if (ret != 0) {
+        return new CommandProcessorResponse(ret, errorMessage, SQLState);
+      }
+    }
+
+    // the reason that we set the txn manager for the cxt here is because each
+    // query has its own ctx object. The txn mgr is shared across the
+    // same instance of Driver, which can run multiple queries.
+    ctx.setHiveTxnManager(txnMgr);
 
     if (ckLock) {
       boolean lockOnlyMapred = HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_LOCK_MAPRED_ONLY);
@@ -1040,9 +1043,6 @@
private CommandProcessorResponse runInternal(String command, boolean alreadyComp
       }
     }
 
-    ret = recordValidTxns();
-    if (ret != 0) return new CommandProcessorResponse(ret, errorMessage, SQLState);
-
     if (requireLock) {
       ret = acquireReadWriteLocks();
       if (ret != 0) {
